import {
    INCREMENTCOUNT,
    DECREMENTCOUNT
} from '../constnant/countConst'


const init = {
    count: 0
}

export default function countReducer(preState = init , action){
    
    const {
        type,
        data
    } = action

    switch(type){
        case INCREMENTCOUNT :
            return {
                ...preState , count: preState.count + data
            }
        case DECREMENTCOUNT :
            return{
                ...preState , count: preState.count - data
            }
    }

    return preState;
}